FROM base.troila.com:9000/library/golang:1.25.0 as builder
COPY . /build
WORKDIR /build
ENV TZ=Asia/Shanghai
RUN go env -w GO111MODULE=on
RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go mod download
RUN go install github.com/swaggo/swag/cmd/swag@latest
RUN go install github.com/zxmfke/swagger2openapi3/cmd/swag2op@latest
RUN swag2op init --nc=false --disOverwrite=true -o=./docs/v2  --openo=./docs/v3
RUN go mod edit -replace xincan.com.cn/tarot-ceph/docs/v2=./docs/v2
RUN go mod tidy
RUN go build -tags netgo -ldflags '-w -s -extldflags "-static"' -o /tarot

FROM base.troila.com:9000/library/ubuntu:24.10

WORKDIR /troila
COPY --from=builder /docs ./docs
COPY --from=builder /tarot ./
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
ENV TZ=Asia/Shanghai
ENV ACTIVE=""
ENTRYPOINT ["/troila/tarot", "-console=true"]
